package com.itany.book.conf;

import com.itany.book.interceptor.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class TestMvcConfig implements WebMvcConfigurer {


    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/showlogin").setViewName("login");
        registry.addViewController("/showregister").setViewName("register");
    }

    // @Override
    // public void addInterceptors(InterceptorRegistry registry) {
    //     // 因为这个interceptor是new出来的，没有交给spring容器管理，
    //     // 所以，无法使用autowired进行注入。
    //     registry.addInterceptor(new MyInterceptor())
    //             .addPathPatterns("/userserver/findUsers");
    // }
}
